//
//  Test13.cpp
//  CPPTest
//
//  Created by you5 Yi on 2021/9/14.
//

#include "Test13.hpp"
#include <string>
#include <iostream>
using namespace std;
class str2
{
private:
    char *st;
public:
    str2(char *a) {
        set(a);
    }
    str2 &operator=(str2 &a)
    {
        delete st;
        set(a.st);
        return *this;
    }
    void show() {
        cout<<st<<endl;
    }
    ~str2() {
        delete st;
    }
    void set(char *s) {
        st=new char[strlen(s)+1];
        strcpy(st, s);
    }
};

void test13() {
    str2 s1("hello"),s2("world");
    s1.show(),s2.show();
    s2=s1;
    s1.show(),s2.show();
}

